package com.mallcai.bigdata.ladon.controller.system.form;

import com.mallcai.bigdata.ladon.controller.BaseForm;
import com.mallcai.bigdata.ladon.dpl.entity.system.Role;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-06-21 10:35.
 * Modify:
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleForm extends BaseForm {

    @NotNull(message = "主键Id不能为空", groups = {IdCheck.class, SaveRoleResCheck.class})
    private Long    roleId;
    @NotBlank(message = "角色名称不能为空", groups = {AddCheck.class, EditCheck.class})
    private String  name;
    @NotBlank(message = "角色编码不能为空", groups = {AddCheck.class, EditCheck.class})
    private String  code;
    @NotNull(message = "角色类型不能为空", groups = {AddCheck.class, EditCheck.class})
    private Integer type;
    private String  desc;

    @NotNull(message = "资源权限信息为空", groups = {SaveRoleResCheck.class})
    private Map<Long, List<Integer>> roleMaskMap; // 资源权限列表

    @NotNull(message = "报表权限信息为空", groups = {SaveRoleReportCheck.class})
    private List<Long> reportIds;

    public interface IdCheck {
    }

    public interface AddCheck {
    }

    public interface EditCheck {
    }

    public interface SaveRoleResCheck {
    }
    public interface SaveRoleReportCheck{
    }


    public Role toEntity() {
        Role role = new Role();
        role.setId(roleId);
        role.setType(type);
        role.setName(name);
        role.setCode(code);
        role.setDesc(desc);
        return role;
    }

}
